'''
Created on 22.12.2011

@author: hkh
'''
from REIBOR import *
from datetime import date

class InterestCurve(object):
    curvepoints = []
    def __init__(self):
        self.initialize()
    def getrate(self):
        for obj in self.curvepoints:
            #print obj.yearfrac()
            print obj.maturitydate
    def test(self):
        self.curvepoints.sort(key=lambda point: point.maturitydate)
        b = self.curvepoints
        #b = sorted(self.curvepoints, key=lambda point: point.maturitydate)
        for obj in b:
            #print obj.yearfrac()
            print obj.maturitydate, obj.discountfactor(), obj.continuousrate(), obj.yearfrac() 
    def initialize(self):
        ddate = date(2011,11,11)
        self.curvepoints.append(REIBOR9M(ddate, 0.02))
        self.curvepoints.append(REIBOR2M(ddate, 0.05))
        self.curvepoints.append(REIBOR3M(ddate, 0.06))
        self.curvepoints.append(REIBOR6M(ddate, 0.02))
        self.curvepoints.append(REIBOR3M(ddate, 0.06))
        self.curvepoints.append(REIBOR12M(ddate, 0.01))
        self.curvepoints.append(REIBOR1M(ddate, 0.04))


a = InterestCurve()
a.getrate()
print 'shit1'
a.test()
print 'shit2'
a.getrate()
print 'shit3'

a = REIBOR6M(date(2011,11,11), 0.04)
print a.discountfactor()
print a.continuousrate()
print a.yearfrac()
